// Copyright Juan-Carlos Maureira 2010
// 
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public License
// along with this program.  If not, see http://www.gnu.org/licenses/.
// 

import inet.world.ScenarioManager;
import inet.nodes.ethernet.EtherSwitch;
import inet.nodes.inet.Router;
import inet.nodes.inet.StandardHost;
import DHCP.DHCPClient;
import DHCP.DHCPServer;
import ned.DatarateChannel;
import inet.applications.udpapp.*;

import channels.MyThroughputMeteringChannel;

channel pppline extends DatarateChannel
{
    delay = 100ms;
    datarate = 1 Gbps;
}
network MeasuringThroughput
{
    @display("bgb=572,495");
    submodules:
        web1: StandardHost {
            @display("p=61,439");
            numUdpApps = 1;
            udpAppType = "DHCP.DHCPClient";
        }
        web2: StandardHost {
            @display("p=513,439");
            numUdpApps = 1;
            udpAppType = "DHCP.DHCPClient";
        }
        router1: Router {
            @display("p=181,283");
            routingFile = "router1.mrt";
        }
        router2: Router {
            @display("p=395,283");
            routingFile = "router2.mrt";
        }
        dhcpServer1: StandardHost {
            @display("p=61,283");
            routingFile = "dhcpServer1.mrt";
            numUdpApps = 1;
            udpAppType = "DHCP.DHCPServer";
        }
        dhcpServer2: StandardHost {
            @display("p=513,283");
            routingFile = "dhcpServer2.mrt";
            numUdpApps = 1;
            udpAppType = "DHCP.DHCPServer";
        }
        etherSwitch: EtherSwitch {
            @display("p=118,368");
        }
        etherSwitch1: EtherSwitch {
            @display("p=458,368");
        }
        router: Router {
            @display("p=293,170");
            routingFile = "router.mrt";
        }
        client: StandardHost {
            @display("p=293,71");
            numUdpApps = 1;
            udpAppType = "UDPVideoStreamCli";
            routingFile = "client.mrt";
        }
        vod2: StandardHost {
            @display("p=434,439");
            numUdpApps = 1;
            udpAppType = "DHCP.DHCPClient";
        }
        vod1: StandardHost {
            @display("p=142,439");
            numUdpApps = 1;
            udpAppType = "DHCP.DHCPClient";
        }
        scenarioManager: ScenarioManager {
            @display("p=118,92");
        }
    connections:
        // Measure the link between the two routers and record the average(b) and current(B) bandwidth
        router1.pppg++ <--> MyThroughputMeteringChannel {  datarate = 1 Gbps; delay = 100us; format = "b B"; } <--> router2.pppg++;

        etherSwitch.ethg++ <--> router1.ethg++;
        etherSwitch.ethg++ <--> dhcpServer1.ethg++;
        etherSwitch.ethg++ <--> web1.ethg++;
        etherSwitch.ethg++ <--> vod1.ethg++;

        etherSwitch1.ethg++ <--> router2.ethg++;
        etherSwitch1.ethg++ <--> dhcpServer2.ethg++;
        etherSwitch1.ethg++ <--> web2.ethg++;
        etherSwitch1.ethg++ <--> vod2.ethg++;

        router.pppg++ <--> pppline <--> client.pppg++;
        router.pppg++ <--> pppline <--> router1.pppg++;
        router.pppg++ <--> pppline <--> router2.pppg++;

}
